#include "game_cron.h"
#include "game_log.h"
#include <unistd.h>
#include "game_ev.h"
#include <functional>

class Listener{
public:
  void hint();
};

void Listener::hint(){
  CC_LOG("Listener","call by CGameCron at %d",time(NULL));
}


int main(){
  
  // g_CGameCron.init();
  UINT64 time;
  CGameCron::next(&time,"0 */2 1-4 * * *");
  C_LOG("%d",time);

  Listener l;


  g_CGameCron.init();

  // auto fn = std::bind(&Listener::hint,&l);
  // fn();

  g_CGameCron.cron(std::bind(&Listener::hint,&l),"0 20 17 * * ?");

  do{
    event_base_loop(g_CGameEV.getBase(), EVLOOP_NONBLOCK);
      // doRun();
      // *((uint8_t*)(0x0)) = 1; // segv error test
    ::usleep(40 * 1000);
  }while(true);

  return 0;
}
